add Type::isNever and Type::isExplicitNever methods#4547
add Type::isNever and Type::isExplicitNever methods#4547canvural wants to merge 5 commits intophpstan:2.1.xfrom
Conversation
|
I disagree about it. There's nothing wrong about this signature: /**
* @template T of BackedEnum
* @param class-string<T> $class
* @param value-of<T> $value
*/I feel like UnresolvableTypeHelper should skip LateResolvableTypes. |
|
I think that'd just hide the error. Currently Edit: I copied the snippet you referenced and the fix from #4548 and looks like that fixes it without the need of skipping LateResolvableTypes in UnresolvableTypeHelper |
|
I'm sorry about sleeping on this. There are now conflicts. Please fix rebase and fix them. At least meanwhile I merged #4548. |
|
Amazing. Yeah, I was waiting for that PR to be merged first. Will do in the evening 👍🏽 |
|
@ondrejmirtes Rebased and refactored new usages to methods too. There is one test failing locally. Here it doesn't report error anymore. @VincentLanglet maybe you have any insights? |
VincentLanglet
left a comment
There was a problem hiding this comment.
When reading the PR, it's unclear to me why sometimes
$exprType instanceof NeverType
is changed to !$exprType->isNever()->no()
and sometimes to $exprType->isNever()->yes()
Is maybe possible ?
- If not, could we have consistency ? (it seems simpler to use
yesthat!no(). - Also if not, I wonder if the method should return boolean... (Or we will end up with not-caught mutant from mutation testing)
| ($otherType instanceof self && !$otherType instanceof TemplateUnionType) | ||
| || ($otherType instanceof IterableType && !$otherType instanceof TemplateIterableType) | ||
| || $otherType instanceof NeverType | ||
| || $otherType->isNever()->yes() |
There was a problem hiding this comment.
| || $otherType->isNever()->yes() | |
| || $otherType instanceof CompoundType && $otherType->isNever()->yes() |
To avoid the error reported maybe ?
There was a problem hiding this comment.
I don't know which error you are referring to. This PR did not cause any additional error, it "fixed" one 😄
There was a problem hiding this comment.
The one you had to ignore in the baseline https://github.com/phpstan/phpstan-src/pull/4547/changes#diff-995edee38ad4f8387e58ebd52c31bcc04c56cc2448d331b1cf5e0b35c57b9efa
No idea like this, the PR is (too) big. |
The issue is that, with this PR an error is not reported whereas the test expects an error. This one phpstan-src/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php Lines 3713 to 3716 in 8e131a9 Can we say the test is wrong now and remove the error from there? |
No. I don't think the test is wrong. |
|
78ca602 fixes it. And doesn't break anything else. |
Nice, I prefer to let ondrej decide if this is the right way. (Maybe LateResolvable::isNever should return no (?))
And about this question ? How did you decide between. |
Initially I replaced them with just normal yes and no. But some tests were failing so I changed the conditions to think about maybe too. So currently if you see |
Re-opening #4545
I think the issue bot changes are valid and is the same case as I described here